package com.io.serializable_;

import java.io.Serializable;

public class Animal implements Serializable {
    // 定义序列化版本号
    private static final long serialVersionUID = 9020549935650296705L;
    private String name;
    private int age;
    // static 静态属性和 transient 不被序列化
    private static String country;
    private transient String color;
    // 序列化对象时，要求里面属性的类型也需要实现序列化接口
    // 例如 数据类型 Dog 必须要实现 Serializable 接口
    private Dog dog = new Dog("测试",20);

    public Animal(String name, int age, String color) {
        this.name = name;
        this.age = age;
        this.color = color;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public static String getCountry() {
        return country;
    }

    public static void setCountry(String country) {
        Animal.country = country;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }
}
